#ifndef _DX_H
#define _DX_H

#include "d3d9.h"
#include "d3dx9math.h"
#include "math.h"
//#include "gol1.h"
//#include "shd.h"

#define TESSELATION 200
#define GRIDLINES 500

#define XDIST 0.3f
#define YDIST 0.3f
#define RES_X 50
#define RES_Y RES_X
#define NUM_LEAVES 2
#define NUM_TRIANGLES 	( NUM_LEAVES * ( 2 * ( RES_X - 1 ) * ( RES_Y - 1) ) )
#define NUM_VERTICES	( NUM_TRIANGLES * 3 )

#define frand()		((float)rand()/32767.0f)
#define clamp( x, a, b )	( x < a ? a : ( x > b ? b : x ) )


typedef struct Vertex
{
	FLOAT x, y, z;
	D3DCOLOR col;
};

typedef struct sCamera
{
    D3DXVECTOR3 vEyePos;
    D3DXVECTOR3 vLookAt;
    D3DXVECTOR3 vUp;
    float       fFov;
    float       fAspect;
    float       fZNear;
    float       fZFar;
};

void   SetCamera();

extern struct sCamera g_Camera;

extern LPDIRECT3D9 g_pD3D;
extern LPDIRECT3DDEVICE9 pDevice;
extern D3DPRESENT_PARAMETERS d3dpp; 


extern struct Vertex  *pVBuf;

extern const DWORD VERTEX_FORMAT;

extern float fXAngle, fYAngle;
extern float fXOffs, fYOffs, fZOffs;

void DXInit( HWND hWnd );
void Loop(HWND hWnd);
void UpdateStats();
void Redraw(HWND hWnd);
void SetCamera();
void Done(	HWND hWnd );

void UpdateMesh1( );
void UpdateMesh2( float );
void SetupMesh( );

#endif //_DX_H

